Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "duplicate key value violates unique constraint" on needle updates #5426

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

Martchus
Copy link
Contributor

  • Use raw SQL queries with "ON CONFLICT DO NOTHING" to avoid running into
    those errors
  • Follow example from OpenQA::Schema::ResultSet::Assets::register where
    we already use raw queries like that followed by an DBIx call to get the
    newly inserted row
  • Not using {for => 'update'} here to locking as we likely don't need it
    here as we don't mind the exact last module
  • Avoid repeated function calls simplifying the code a little bit
  • See https://progress.opensuse.org/issues/153616

This helps on systems where another timezone is generally used (and thus
also used by PostgreSQL) to get consistent behavior when running tests.

Note that this is relevant for code that uses the SQL function `now()`
instead of `DBIx::Class::Timestamps::now` which already always uses UTC
anyway.
@Martchus
Copy link
Contributor Author

Of course it would be great to test this as suggested here: https://progress.opensuse.org/issues/153616#Suggestions

However, I would have to find out how to bring this change into the test setup first.

@asdil12
Copy link
Member

asdil12 commented Jan 16, 2024

However, I would have to find out how to bring this change into the test setup first.

This is not trivial.
You would have to build RPMs and modify line 16 in tests/install/openqa_webui.pm (in os-autoinst-distri-openQA) to use that repo instead of devel:openQA.

* Use raw SQL queries with "ON CONFLICT DO NOTHING" to avoid running into
  those errors
* Follow example from `OpenQA::Schema::ResultSet::Assets::register` where
  we already use raw queries like that followed by an DBIx call to get the
  newly inserted row
* Not using `{for => 'update'}` here to locking as we likely don't need it
  here as we don't mind the *exact* last module
* Avoid repeated function calls simplifying the code a little bit
* See https://progress.opensuse.org/issues/153616
Copy link

codecov bot commented Jan 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5365490) 98.37% compared to head (bf3149e) 98.37%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5426   +/-   ##
=======================================
  Coverage   98.37%   98.37%           
=======================================
  Files         389      389           
  Lines       37724    37728    +4     
=======================================
+ Hits        37112    37116    +4     
  Misses        612      612           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mergify mergify bot merged commit 44c5265 into os-autoinst:master Jan 16, 2024
13 checks passed
@Martchus Martchus deleted the needle-race-cond branch January 16, 2024 15:43
@asdil12
Copy link
Member

asdil12 commented Jan 16, 2024

Looks very good: https://openqa.opensuse.org/tests/overview?version=Tumbleweed&build=dheidler_mm3_ping&distri=openqa&groupid=38

The first 10 out of 10 all passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants